package com.sbc.user.handler.chain;

import com.sbc.convention.exception.ClientException;
import com.sbc.user.pojo.vo.UserRegisterReqVo;
import com.sbc.user.service.UserInfoService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * @description: 用户注册检查证件号是否多次注销
 * @author: songbaicheng
 * @create: 2024-05-30 15:17
 **/
@Component
@RequiredArgsConstructor
public class UserRegisterCheckDeletionChainHandler implements UserRegisterCreateChainFilter<UserRegisterReqVo> {

    private final UserInfoService userInfoService;

    @Override
    public void handler(UserRegisterReqVo requestParam) {
        Integer userDeletionNum = userInfoService.queryUserDeletionNum(requestParam.getIdType(), requestParam.getIdCard());
        if (userDeletionNum >= 5) {
            throw new ClientException("证件号多次注销账号已被加入黑名单");
        }
    }

    @Override
    public int getOrder() {
        return 2;
    }
}
